﻿@{
    ViewBag.Title = "Banner";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div ng-controller="EditableRowCtrl" class="banner-page">
    <a class="btn btn-default" href="/Banner/Create">Add New Banner</a>
    <br />
    <table class="table table-bordered table-hover table-condensed">
        <tr style="font-weight: bold">
            <td style="width: 50%">Image</td>
            <td style="width: 25%">Url</td>
            <td style="width: 25%">Action</td>
        </tr>
        <tr ng-repeat="banner in banners">
            <td>
                <!-- editable (text with validation) -->
                <img ng-src="{{banner.imageUrl}}" alt="" />
            </td>
            <td>
                <!-- editable (text with validation) -->
                <span>{{banner.linkUrl}}
                </span>
            </td>

            <td style="white-space: nowrap">
                <!-- form -->
                <div class="buttons" ng-show="!rowform.$visible">
                    <a class="btn btn-primary" href="/Banner/Edit/{{banner.id}}">Edit </a>
                    <a class="btn btn-danger" data-toggle="modal" data-target="#myModal-{{$index}}">Delete</a>
                </div>
                <div class="modal fade" id="myModal-{{$index}}">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h4 class="modal-title">Confirm</h4>
                            </div>
                            <div class="modal-body">
                                <p>Are you sure to delete?</p>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
                                <button type="button" class="btn btn-primary" ng-click="removeBanner($index)">Yes</button>
                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                </div>
            </td>
        </tr>
    </table>

    <a class="btn btn-default" href="/Banner/Create">Add New Banner</a>

</div>
@section scripts{
    <script type="text/javascript" src="/Scripts/app/banner.js"></script>
}